package cd.cdyb.sms.controller;


import cd.cdyb.sms.dto.PageResult;
import cd.cdyb.sms.dto.expand.ExCompanyDto;
import cd.cdyb.sms.dto.query.CompanyQueryDto;
import cd.cdyb.sms.exception.BusinessException;
import cd.cdyb.sms.service.CompanyService;
import cd.cdyb.sms.service.InventoryService;
import cn.hutool.core.util.RandomUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lin
 * @since 2024-05-14
 */
@RestController
@RequestMapping("/inventory")
public class InventoryController {


    @Resource
    private InventoryService inventoryService;

    /**
     * 新增
     */
    @PostMapping("/test")
    public void test()  {
        Thread thread = new Thread() {
            @Override
            public void run() {
                while (true){
                    int i = RandomUtil.randomInt(0, 1000);
                    try {
                        Thread.sleep(i);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
//                    inventoryService.increaseInventory(10, 1, 2);
                }
            }
        };

        Thread thread2 = new Thread() {
            @Override
            public void run() {
                while (true){
                    int i = RandomUtil.randomInt(0, 1000);
                    try {
                        Thread.sleep(i);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
//                    inventoryService.reduceInventory(10, 1, 2);
                }
            }
        };
        thread.start();
        thread2.start();
    }

}

